/*
 *  Copyright (C) void Team 2010 Pedro Batista
 * 
 *  http://code.google.com/p/capacitec
 * 
 *  This file is part of capacitec.
 * 
 *  capacitec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  capacitec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with capacitec.  If not, see <http://www.gnu.org/licenses/>.
 */

package entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author pedro
 */
@Entity
@Table(name = "aluno_subprograma")
@NamedQueries({
	@NamedQuery(name = "AlunoSubPrograma.findAll", query = "SELECT a FROM AlunoSubPrograma a"),
	@NamedQuery(name = "AlunoSubPrograma.findByAlunoPessoaId", query = "SELECT a FROM AlunoSubPrograma a WHERE a.alunoSubProgramaPK.alunoPessoaId = :alunoPessoaId"),
	@NamedQuery(name = "AlunoSubPrograma.findBySubProgramaid", query = "SELECT a FROM AlunoSubPrograma a WHERE a.alunoSubProgramaPK.subProgramaid = :subProgramaid"),
	@NamedQuery(name = "AlunoSubPrograma.findBySituacao", query = "SELECT a FROM AlunoSubPrograma a WHERE a.situacao = :situacao")})
public class AlunoSubPrograma implements Serializable {
	private static final long serialVersionUID = 1L;
	@EmbeddedId
	protected AlunoSubProgramaPK alunoSubProgramaPK;
	@Basic(optional = false)
        @Column(name = "situacao", nullable = false, length = 10)
	private String situacao;
	@JoinColumn(name = "subPrograma_id", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
        @ManyToOne(optional = false)
	private SubPrograma subPrograma;
	@JoinColumn(name = "aluno_pessoa_id", referencedColumnName = "pessoa_id", nullable = false, insertable = false, updatable = false)
        @ManyToOne(optional = false)
	private Aluno aluno;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "alunoSubPrograma")
	private List<AlunoSubProgramaTurma> alunoSubProgramaTurmaList;

	public AlunoSubPrograma() {
	}

	public AlunoSubPrograma(AlunoSubProgramaPK alunoSubProgramaPK) {
		this.alunoSubProgramaPK = alunoSubProgramaPK;
	}

	public AlunoSubPrograma(AlunoSubProgramaPK alunoSubProgramaPK, String situacao) {
		this.alunoSubProgramaPK = alunoSubProgramaPK;
		this.situacao = situacao;
	}

	public AlunoSubPrograma(int alunoPessoaId, int subProgramaid) {
		this.alunoSubProgramaPK = new AlunoSubProgramaPK(alunoPessoaId, subProgramaid);
	}

	public AlunoSubProgramaPK getAlunoSubProgramaPK() {
		return alunoSubProgramaPK;
	}

	public void setAlunoSubProgramaPK(AlunoSubProgramaPK alunoSubProgramaPK) {
		this.alunoSubProgramaPK = alunoSubProgramaPK;
	}

	public String getSituacao() {
		return situacao;
	}

	public void setSituacao(String situacao) {
		this.situacao = situacao;
	}

	public SubPrograma getSubPrograma() {
		return subPrograma;
	}

	public void setSubPrograma(SubPrograma subPrograma) {
		this.subPrograma = subPrograma;
	}

	public Aluno getAluno() {
		return aluno;
	}

	public void setAluno(Aluno aluno) {
		this.aluno = aluno;
	}

	public List<AlunoSubProgramaTurma> getAlunoSubProgramaTurmaList() {
		return alunoSubProgramaTurmaList;
	}

	public void setAlunoSubProgramaTurmaList(List<AlunoSubProgramaTurma> alunoSubProgramaTurmaList) {
		this.alunoSubProgramaTurmaList = alunoSubProgramaTurmaList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (alunoSubProgramaPK != null ? alunoSubProgramaPK.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof AlunoSubPrograma)) {
			return false;
		}
		AlunoSubPrograma other = (AlunoSubPrograma) object;
		if ((this.alunoSubProgramaPK == null && other.alunoSubProgramaPK != null) || (this.alunoSubProgramaPK != null && !this.alunoSubProgramaPK.equals(other.alunoSubProgramaPK))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "entidades.AlunoSubPrograma[alunoSubProgramaPK=" + alunoSubProgramaPK + "]";
	}

}
